package com.appspot.etao.model;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.taobao.top.domain.ItemCat;

public class ItemCatModel extends BaseModel {

	private static final long serialVersionUID = -7007030431658767713L;
	
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;

    /** 类目编号 */
    @Persistent
	private String cid;

    /** 类目名称 */
    @Persistent
    private String parentCid;

    /** 父类目编号 */
    @Persistent
	private String name;

    /** 该类目是否为父类目 */
    @Persistent
	private boolean isParent;

    /** 类目状态 */
    @Persistent
	private String status;

    /** 类目排列序号 */
    @Persistent
	private int sortOrder;
    
    /** 类目地址 */
    @Persistent
    private String url;
    
    /** 类目下商品的数量 */
    @Persistent
    private Long itemCount;
    
    /** 本地属性， 为了避免一次性获取淘宝数据超时，采用分批取数的办法，该属性用来控制相应类目下的数据是否已经获取 */
    @Persistent
    private boolean isCatched;
    
    private ItemCat itemCat;
    
    public ItemCatModel() {
    	isCatched = false;
    }
    
    public ItemCatModel(ItemCat itemCat) {
    	isCatched = false;
    	
    	setItemCat(itemCat);
    }

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCid() {
		return cid;
	}

	public void setCid(String cid) {
		this.cid = cid;
	}

	public String getParentCid() {
		return parentCid;
	}

	public void setParentCid(String parentCid) {
		this.parentCid = parentCid;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isParent() {
		return isParent;
	}

	public void setParent(boolean isParent) {
		this.isParent = isParent;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public int getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(int sortOrder) {
		this.sortOrder = sortOrder;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Long getItemCount() {
		return itemCount;
	}

	public void setItemCount(Long itemCount) {
		this.itemCount = itemCount;
	}

	public boolean isCatched() {
		return isCatched;
	}

	public void setCatched(boolean isCatched) {
		this.isCatched = isCatched;
	}

	public ItemCat getItemCat() {
		return itemCat;
	}

	public void setItemCat(ItemCat itemCat) {
		this.itemCat = itemCat;
		
		this.cid = itemCat.getCid().toString();
		this.parentCid = itemCat.getParentCid().toString();
		this.name = itemCat.getName();
		this.isParent = itemCat.isParent();
		this.status = itemCat.getStatus();
		this.sortOrder = itemCat.getSortOrder();
		
		this.url = itemCat.getUrl();
		this.itemCount = itemCat.getItemCount();
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer("");
		
		sb.append("[");
		sb.append(cid);
		sb.append(",");
		sb.append(parentCid);
		sb.append(",");
		sb.append(name);
		sb.append(",");
		sb.append(isParent);
		sb.append(",");
		sb.append(status);
		sb.append(",");
		sb.append(sortOrder);
		sb.append(",");
		sb.append(url);
		sb.append(",");
		sb.append(itemCount);
		sb.append("]");
		
		return sb.toString();
	}

}
